﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Miris.HumanMilkAnalyser.DataModel;

namespace Miris.HumanMilkAnalyser.Service.Validation
{
    public class BreastfeedingSignificanceValidator : DataValidatorBase<BreastfeedingSignificance>
    {
        public const string TitleErrorKey = "Title";
        public const string SignificanceContentErrorKey = "SignificanceContent";

        /// <summary>
        /// Validate the provided entity. Then check the IsValid property to see the result.
        /// </summary>
        /// <param name="entity">The provided entity to be validated.</param>
        public override void Validate(BreastfeedingSignificance entity) { }

        /// <summary>
        /// Check if the required Title is provided.
        /// </summary>
        /// <param name="entity">The instance of BreastfeedingSignificance.</param>
        /// <returns>True means passed. False means failed.</returns>
        public bool CheckRequiredTitle(BreastfeedingSignificance entity)
        {
            if (!ValidationHelper.RuleCheckRequiredContent(entity.Title))
            {
                AddError(TitleErrorKey, "标题不能为空");
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// Check if the required SignificanceContent is provided.
        /// </summary>
        /// <param name="entity">The instance of BreastfeedingSignificance.</param>
        /// <returns>True means passed. False means failed.</returns>
        public bool CheckRequiredSignificanceContent(BreastfeedingSignificance entity)
        {
            if (!ValidationHelper.RuleCheckRequiredContent(entity.SignificanceContent))
            {
                AddError(SignificanceContentErrorKey, "内容不能为空");
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
